import 'package:dss_base/dss_base.dart';
import 'package:dss_base/global/config.dart';
import 'package:flutter_demo_test/module/env_util.dart';

class HttpInit extends ModuleInitProvider {
  @override
  init() {
    final List<Interceptor> interceptors = [CommonHeaderInterceptor()];
    if (isDebug) {
      interceptors.add(MyLogInterceptor(
        request: false,
        responseHeader: false,
        logPrint: (msg){
          print('flutter_http_log: $msg');
        },
      ));
    }
    HttpUtil.instance.init(
      baseUrl: EnvUtil.baseUrl,
      defaultFailureCallback: (code, msg) => Toast.show(msg),
      connectTimeout: Duration(seconds: 10),
      receiveTimeout: Duration(seconds: 10),
      sendTimeout: Duration(seconds: 10),
      interceptors: interceptors,
    );
  }
}
